package com.huawei.appmarket.service.store.awk.card;

import android.annotation.SuppressLint;
import android.content.Context;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.foundation.card.base.normal.bean.NormalCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import com.huawei.appgallery.horizontalcard.api.card.BaseHorizontalItemCard;
import com.huawei.appmarket.framework.widget.RoundCornerLayout;
import com.huawei.appmarket.service.store.awk.bean.HorizontalBigImageItemBean;
import com.huawei.appmarket.support.video.VideoPlayer;
import com.huawei.hwid.core.constants.HwAccountConstants;
import o.cgz;
import o.chc;
import o.chy;
import o.Logger;
import o.dof;
import o.ContentManager;
import o.epv;
import o.eqx;
import o.evp.b;
import o.evt;
import o.evx;
import o.ewm.d;
import o.ewm.h;
import o.ewm.j;

public class HorizontalBigImgItemCard extends BaseHorizontalItemCard {
    protected ImageView ʻ;
    protected TextView ʼ;
    protected ViewGroup ʽ;
    protected ImageView ˊॱ;
    protected final int ˋ;
    protected LinearLayout ˏॱ;
    protected evx ͺ;
    protected RoundCornerLayout ॱˊ;
    protected VideoPlayer ॱॱ;
    protected final int ᐝ;

    public HorizontalBigImgItemCard(Context context) {
        super(context);
        this.ˋ = context.getResources().getDimensionPixelSize(d.ॱʽ);
        this.ᐝ = context.getResources().getDimensionPixelSize(d.ॱʼ);
    }

    public static int ॱˊ() {
        return chc.ॱˋ();
    }

    public cgz ˏ(View view) {
        this.ˏॱ = (LinearLayout) view.findViewById(j.ॱـ);
        ˏ((ImageView) view.findViewById(j.ʽꜝ));
        ॱ((TextView) view.findViewById(j.ˊʻ));
        ˊ((TextView) view.findViewById(j.ˋ));
        this.ʻ = (ImageView) view.findViewById(j.ᐣॱ);
        ˋ((DownloadButton) view.findViewById(j.ᵣ));
        this.ʽ = (ViewGroup) view.findViewById(j.ᐝʼ);
        this.ʼ = (TextView) view.findViewById(j.ㆍʼ);
        ʽ(view);
        ॱॱ();
        return this;
    }

    protected void ॱॱ() {
        int ˎ = epv.ˎ(this.ʼॱ, ॱˊ(), chc.ˋ());
        this.ˏॱ.setLayoutParams(new LayoutParams(ˎ, (int) (((float) ˎ) * epv.ʼ())));
        LayoutParams layoutParams = (LayoutParams) this.ʽ.getLayoutParams();
        layoutParams.width = ˎ;
        this.ʽ.setLayoutParams(layoutParams);
    }

    @SuppressLint({"SetTextI18n"})
    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof HorizontalBigImageItemBean) {
            HorizontalBigImageItemBean horizontalBigImageItemBean = (HorizontalBigImageItemBean) cardBean;
            if (horizontalBigImageItemBean.ٴ() != 0) {
                this.ʻ.setVisibility(0);
                eqx.ˎ(this.ʻ, horizontalBigImageItemBean.ՙ());
                this.ˉ.setText(horizontalBigImageItemBean.ߴ());
            } else {
                this.ʻ.setVisibility(8);
            }
            if (Logger.ˎ()) {
                Logger.ˏ("HorizontalBigImgItemCard", "bean.getVideoUrl_()=" + horizontalBigImageItemBean.ॱꜟ());
            }
            int i = j.ʿˈ;
            int i2 = j.ʿʿ;
            String str = (String) this.ʽ.getTag(i);
            String str2 = (String) this.ʽ.getTag(i2);
            if (!dof.ˋ(str) && str.equals(horizontalBigImageItemBean.ॱꜟ())) {
                return;
            }
            if (dof.ˋ(str2) || !str2.equals(horizontalBigImageItemBean.ॱﾞ())) {
                str = horizontalBigImageItemBean.ॱﾞ();
                this.ʽ.setTag(i, horizontalBigImageItemBean.ॱꜟ());
                this.ʽ.setTag(i2, str);
                ˋ(this.ʼ, horizontalBigImageItemBean.ˋʻ());
                if (horizontalBigImageItemBean.ʽ() != 0) {
                    ˋˊ().setText(DateUtils.formatDateTime(this.ʼॱ, horizontalBigImageItemBean.ʽ(), 16) + HwAccountConstants.BLANK + horizontalBigImageItemBean.ˊʻ());
                }
                if (TextUtils.isEmpty(horizontalBigImageItemBean.ॱꜟ())) {
                    this.ˏॱ.removeView(this.ॱˊ);
                    this.ॱˊ = null;
                    this.ॱॱ = null;
                    ॱ(horizontalBigImageItemBean);
                    return;
                }
                this.ˏॱ.removeView(this.ˊॱ);
                this.ˊॱ = null;
                ˎ(horizontalBigImageItemBean);
            }
        }
    }

    protected int ao_() {
        return h.ॱꜟ;
    }

    private void ॱ(HorizontalBigImageItemBean horizontalBigImageItemBean) {
        Context ˋ = ContentManager.getInstant().getContext();
        if (this.ˊॱ == null) {
            this.ˊॱ = (ImageView) LayoutInflater.from(ˋ).inflate(h.ॱﾞ, this.ˏॱ, false);
            this.ˏॱ.addView(this.ˊॱ);
        }
        if (this.ˊॱ != null) {
            eqx.ˋ(this.ˋ, this.ᐝ, this.ˊॱ, horizontalBigImageItemBean.ॱﾞ());
            this.ˊॱ.setContentDescription(horizontalBigImageItemBean.ʽᐝ());
            this.ˊॱ.setOnClickListener(this.ͺ);
        }
    }

    private void ˎ(HorizontalBigImageItemBean horizontalBigImageItemBean) {
        if (this.ॱˊ == null || this.ॱॱ == null) {
            this.ॱˊ = (RoundCornerLayout) LayoutInflater.from(this.ʼॱ).inflate(ao_(), this.ˏॱ, false);
            this.ॱॱ = (VideoPlayer) this.ॱˊ.findViewById(j.ॱꓸ);
            this.ˏॱ.addView(this.ॱˊ);
        }
        if (this.ॱॱ != null) {
            this.ॱॱ.setVideoBaseInfo(new b().ˎ(horizontalBigImageItemBean.ॱꞌ()).ˊ(horizontalBigImageItemBean.ॱﾞ()).ˋ(horizontalBigImageItemBean.ॱꜟ()).ˏ(horizontalBigImageItemBean.ͺˏ()).ॱ(horizontalBigImageItemBean.u_()).ʼ(horizontalBigImageItemBean.ᐧॱ()).ᐝ(horizontalBigImageItemBean.ᐝʽ()).ʻ(evt.ˏ(horizontalBigImageItemBean.sp_)).ॱॱ(horizontalBigImageItemBean.ॱـ()).ॱ());
            eqx.ˋ(this.ˋ, this.ᐝ, this.ॱॱ.ॱॱ(), horizontalBigImageItemBean.ॱﾞ());
            this.ॱॱ.ॱॱ().setContentDescription(horizontalBigImageItemBean.v_());
            this.ॱॱ.ॱॱ().setOnClickListener(this.ͺ);
        }
    }

    protected evx ˏ(final chy o_chy) {
        return new evx(this) {
            final /* synthetic */ HorizontalBigImgItemCard ˊ;

            public void ˋ(View view) {
                o_chy.ˏ(0, this.ˊ);
            }
        };
    }

    public void ॱ(BaseDistCardBean baseDistCardBean) {
        if (this.ˊ != null) {
            this.ˊ.setVisibility(0);
            this.ˊ.setParam(baseDistCardBean);
            ॱ(this.ˊ.ॱ());
        }
    }

    public int ˊ() {
        return h.ʼˊ;
    }

    public int ˎ() {
        return h.ʼˊ;
    }

    public void ॱ(chy o_chy) {
        this.ͺ = ˏ(o_chy);
        ˉ().setOnClickListener(this.ͺ);
        ʼॱ().setOnClickListener(this.ͺ);
    }

    public void x_() {
        if ((this.ˊᐝ instanceof NormalCardBean) && this.ˉ != null) {
            this.ˉ.setText(((NormalCardBean) this.ˊᐝ).ˏˏ());
        }
    }

    public void w_() {
        eqx.ˏ(this.ʽॱ, this.ˊᐝ.ॱˌ(), "app_default_icon");
    }
}
